<?php

namespace common\model;

use think\model\RelationModel;

class OrderTaskUpstreamVersionModel extends RelationModel
{
    //自动验证
    protected $_validate = [
        ['from_tenant_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['to_tenant_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段

        ['from_project_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['to_project_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段

        ['task_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['version_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段

        ['is_download', ['yes', 'no'], '', self::EXISTS_VALIDATE, 'in'], // 是否下载
        ['is_unzip', ['yes', 'no'], '', self::EXISTS_VALIDATE, 'in'], // 是否解压
        ['from_tenant_id', '', '', self::EXISTS_VALIDATE, 'integer'], // 租户id
        ['to_tenant_id', '', '', self::EXISTS_VALIDATE, 'integer'], // 租户id
        ['task_id', '', '', self::EXISTS_VALIDATE, 'integer'],
        ['created_by', '', '', self::EXISTS_VALIDATE, 'integer'],
        ['download_at', '', '', self::EXISTS_VALIDATE, 'integer'],
        ['created', '', '', self::EXISTS_VALIDATE, 'integer'],
        ['updated', '', '', self::EXISTS_VALIDATE, 'integer'],
        ['from_tenant_id,to_tenant_id,task_id,version_id', '', '', self::MUST_VALIDATE, 'unique'],


    ];

    //自动完成
    protected $_auto = [
        ['created_by', 'fill_created_by', self::MODEL_INSERT, 'function'],
        ['created', 'time', self::MODEL_INSERT, 'function'],
        ['updated', 'time', self::MODEL_BOTH, 'function'],
    ];

}
